extends CanvasLayer

signal upgrade_selected(upgrade:AbilityUpgrade)

@export var upgrade_card_scene: PackedScene
@onready var card_container: HBoxContainer = %CardContainer

func _ready() -> void:
	get_tree().paused = true

# Called when the node enters the scene tree for the first time.
func set_ability_upgrades(upgrades: Array[AbilityUpgrade]):
	for upgrade in upgrades:
		var card_instance = upgrade_card_scene.instantiate()
		card_container.add_child(card_instance)
		card_instance.set_ability_upgrade(upgrade)
		# 连接升级卡片的选择信号
		card_instance.upgrade_card_selected.connect(_on_upgrade_card_selected.bind(upgrade))

func _on_upgrade_card_selected(upgrade: AbilityUpgrade):

	
	upgrade_selected.emit(upgrade)
	# 关闭升级界面
	queue_free()
	get_tree().paused = false
